import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 配置一级路由
  // 注册页
  { path: '/register', component: () => import('@/views/Register.vue') },
  // 登录页
  { path: '/login', component: () => import('@/views/Login.vue') },
  // 详情页
  { path: '/detail/:id', component: () => import('@/views/Detail.vue') },
  // 首页
  {
    path: '/',
    component: () => import('@/views/Home.vue'),
    redirect: '/article',
    children: [
      // 面经列表
      {
        path: 'article',
        component: () => import('@/views/Layout/Article.vue')
      },
      // 收藏页
      {
        path: 'collect',
        component: () => import('@/views/Layout/Collect.vue')
      },
      // 喜欢
      {
        path: 'like',
        component: () => import('@/views/Layout/Like.vue')
      },
      // 用户
      {
        path: 'user',
        component: () => import('@/views/Layout/User.vue')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
